/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.sdcache.distributed.managment;

import com.sun.enterprise.ee.cms.core.CallBack;
import com.sun.enterprise.ee.cms.core.MessageSignal;
import com.sun.enterprise.ee.cms.core.Signal;

/**
 *
 * @author chaitanya
 */
public class MessageCallback implements CallBack
{
 public void processNotification(Signal signal) {
        try {

            signal.acquire();
            if (signal instanceof MessageSignal) {
                MessageSignal msignal=(MessageSignal)signal;
                System.out.println(
                        ":Message Received from:"
                        + signal.getMemberToken()
                        + ":[" + new String(msignal.getMessage()) + "]");
            } else {
                System.out.println(
                        ":Other Notification Received from:"
                        + signal.getMemberToken() + ":["
                        + signal.toString() + "]");
            }
            signal.release();
        } catch (Exception e) {
        }
    }
}
